package com.example.wechatapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class Adapter extends RecyclerView.Adapter<Adapter.myviewholder> {
    private List<ImageMassage> list;
    private Context context;
    private View inflater;

    public Adapter(List<ImageMassage> peakyList) {
        list = peakyList;
    }

    @Override
    public Adapter.myviewholder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        inflater = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.tab03_staggeredrecyclerview,viewGroup,false);
        myviewholder myviewholder = new myviewholder(inflater);
        return myviewholder;
    }

    @Override
    public void onBindViewHolder(@NonNull Adapter.myviewholder holder, int position) {
        ImageMassage peaky = list.get(position);
        holder.peakyImage.setImageResource(peaky.getimageid());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class myviewholder extends RecyclerView.ViewHolder{
        View peakyView;
        ImageView peakyImage;
        public myviewholder(@NonNull View itemView) {
            super(itemView);
            peakyView = itemView;
            peakyImage = itemView.findViewById(R.id.iv);
        }
    }
}

